import time
import uuid
import requests
import re


page = 0
while True:
    page += 1
    url = 'https://api-tinyvideo-web.yy.com/home/tinyvideosv2'
    params = {
        'appId': 'svwebpc',
        'sign': '',
        'data': '{"uid":0,"page":%s,"pageSize":10}' % str(page),
        '_': '1613628479737',
    }
    headers = {
        'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36'
    }
    response = requests.get(url=url, params=params, headers=headers)
    json_data = response.json()
    result = json_data['data']['data']
    for index in result:
        video_url = index['resurl']
        new_title = str(uuid.uuid4())
        video_content = requests.get(url=video_url, headers=headers).content
        with open('yyvideo\\' + new_title + '.mp4', mode='wb') as f:
            f.write(video_content)
            print(new_title)

    time.sleep(0.2)